package Homework0819;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws Exception {
        Person person = new Person();
        person.eat("amm");
        System.out.println(person);

        Class c=Class.forName("Homework0819.Person");
        String name=c.getName();
        String type=c.getTypeName();
        Package packageName=c.getPackage();

        System.out.println(name);
        System.out.println(type);
        System.out.println(packageName);

        System.out.println("input:");
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        Class c1=Class.forName(s);
        Method[] methods=c1.getMethods();
        System.out.println(methods.length);
        for(Method method : methods)
        {
            System.out.println(method.getName());
        }

//        Class c=Class.forName("Homework0819.Person");
//        Object o=c.newInstance();
//        System.out.println(o);
//        Method method = c.getMethod("eat",String.class);
//        method.invoke(o);
    }
}
